<?php


/*
* Copyright (c) 2008-2016 vip.com, All Rights Reserved.
*
* Powered by com.vip.osp.osp-idlc-2.5.11.
*
*/

namespace com\vip\product\portal\model\vop;

class CreateCommonSizeRecommendTableReq {
	
	static $_TSPEC;
	public $name = null;
	public $brand_id = null;
	public $category_id = null;
	public $tips = null;
	public $height_step = null;
	public $min_height = null;
	public $max_height = null;
	public $weight_step = null;
	public $min_weight = null;
	public $max_weight = null;
	public $detail_list = null;
	
	public function __construct($vals=null){
		
		if (!isset(self::$_TSPEC)){
			
			self::$_TSPEC = array(
			1 => array(
			'var' => 'name'
			),
			2 => array(
			'var' => 'brand_id'
			),
			3 => array(
			'var' => 'category_id'
			),
			4 => array(
			'var' => 'tips'
			),
			5 => array(
			'var' => 'height_step'
			),
			6 => array(
			'var' => 'min_height'
			),
			7 => array(
			'var' => 'max_height'
			),
			8 => array(
			'var' => 'weight_step'
			),
			9 => array(
			'var' => 'min_weight'
			),
			10 => array(
			'var' => 'max_weight'
			),
			11 => array(
			'var' => 'detail_list'
			),
			
			);
			
		}
		
		if (is_array($vals)){
			
			
			if (isset($vals['name'])){
				
				$this->name = $vals['name'];
			}
			
			
			if (isset($vals['brand_id'])){
				
				$this->brand_id = $vals['brand_id'];
			}
			
			
			if (isset($vals['category_id'])){
				
				$this->category_id = $vals['category_id'];
			}
			
			
			if (isset($vals['tips'])){
				
				$this->tips = $vals['tips'];
			}
			
			
			if (isset($vals['height_step'])){
				
				$this->height_step = $vals['height_step'];
			}
			
			
			if (isset($vals['min_height'])){
				
				$this->min_height = $vals['min_height'];
			}
			
			
			if (isset($vals['max_height'])){
				
				$this->max_height = $vals['max_height'];
			}
			
			
			if (isset($vals['weight_step'])){
				
				$this->weight_step = $vals['weight_step'];
			}
			
			
			if (isset($vals['min_weight'])){
				
				$this->min_weight = $vals['min_weight'];
			}
			
			
			if (isset($vals['max_weight'])){
				
				$this->max_weight = $vals['max_weight'];
			}
			
			
			if (isset($vals['detail_list'])){
				
				$this->detail_list = $vals['detail_list'];
			}
			
			
		}
		
	}
	
	
	public function getName(){
		
		return 'CreateCommonSizeRecommendTableReq';
	}
	
	public function read($input){
		
		$input->readStructBegin();
		while(true){
			
			$schemeField = $input->readFieldBegin();
			if ($schemeField == null) break;
			$needSkip = true;
			
			
			if ("name" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->name);
				
			}
			
			
			
			
			if ("brand_id" == $schemeField){
				
				$needSkip = false;
				$input->readI32($this->brand_id); 
				
			}
			
			
			
			
			if ("category_id" == $schemeField){
				
				$needSkip = false;
				$input->readI32($this->category_id); 
				
			}
			
			
			
			
			if ("tips" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->tips);
				
			}
			
			
			
			
			if ("height_step" == $schemeField){
				
				$needSkip = false;
				$input->readI32($this->height_step); 
				
			}
			
			
			
			
			if ("min_height" == $schemeField){
				
				$needSkip = false;
				$input->readI32($this->min_height); 
				
			}
			
			
			
			
			if ("max_height" == $schemeField){
				
				$needSkip = false;
				$input->readI32($this->max_height); 
				
			}
			
			
			
			
			if ("weight_step" == $schemeField){
				
				$needSkip = false;
				$input->readI32($this->weight_step); 
				
			}
			
			
			
			
			if ("min_weight" == $schemeField){
				
				$needSkip = false;
				$input->readI32($this->min_weight); 
				
			}
			
			
			
			
			if ("max_weight" == $schemeField){
				
				$needSkip = false;
				$input->readI32($this->max_weight); 
				
			}
			
			
			
			
			if ("detail_list" == $schemeField){
				
				$needSkip = false;
				
				$this->detail_list = array();
				$_size0 = 0;
				$input->readListBegin();
				while(true){
					
					try{
						
						$elem0 = null;
						
						$elem0 = new \com\vip\product\portal\model\vop\SizeRecommendDetail();
						$elem0->read($input);
						
						$this->detail_list[$_size0++] = $elem0;
					}
					catch(\Exception $e){
						
						break;
					}
				}
				
				$input->readListEnd();
				
			}
			
			
			
			if($needSkip){
				
				\Osp\Protocol\ProtocolUtil::skip($input);
			}
			
			$input->readFieldEnd();
		}
		
		$input->readStructEnd();
		
		
		
	}
	
	public function write($output){
		
		$xfer = 0;
		$xfer += $output->writeStructBegin();
		
		$xfer += $output->writeFieldBegin('name');
		$xfer += $output->writeString($this->name);
		
		$xfer += $output->writeFieldEnd();
		
		$xfer += $output->writeFieldBegin('brand_id');
		$xfer += $output->writeI32($this->brand_id);
		
		$xfer += $output->writeFieldEnd();
		
		$xfer += $output->writeFieldBegin('category_id');
		$xfer += $output->writeI32($this->category_id);
		
		$xfer += $output->writeFieldEnd();
		
		if($this->tips !== null) {
			
			$xfer += $output->writeFieldBegin('tips');
			$xfer += $output->writeString($this->tips);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		$xfer += $output->writeFieldBegin('height_step');
		$xfer += $output->writeI32($this->height_step);
		
		$xfer += $output->writeFieldEnd();
		
		$xfer += $output->writeFieldBegin('min_height');
		$xfer += $output->writeI32($this->min_height);
		
		$xfer += $output->writeFieldEnd();
		
		$xfer += $output->writeFieldBegin('max_height');
		$xfer += $output->writeI32($this->max_height);
		
		$xfer += $output->writeFieldEnd();
		
		$xfer += $output->writeFieldBegin('weight_step');
		$xfer += $output->writeI32($this->weight_step);
		
		$xfer += $output->writeFieldEnd();
		
		$xfer += $output->writeFieldBegin('min_weight');
		$xfer += $output->writeI32($this->min_weight);
		
		$xfer += $output->writeFieldEnd();
		
		$xfer += $output->writeFieldBegin('max_weight');
		$xfer += $output->writeI32($this->max_weight);
		
		$xfer += $output->writeFieldEnd();
		
		$xfer += $output->writeFieldBegin('detail_list');
		
		if (!is_array($this->detail_list)){
			
			throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
		}
		
		$output->writeListBegin();
		foreach ($this->detail_list as $iter0){
			
			
			if (!is_object($iter0)) {
				
				throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
			}
			
			$xfer += $iter0->write($output);
			
		}
		
		$output->writeListEnd();
		
		$xfer += $output->writeFieldEnd();
		
		$xfer += $output->writeFieldStop();
		$xfer += $output->writeStructEnd();
		return $xfer;
	}
	
}

?>